package com.jbp.job;

import com.jbp.redis.RedisConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**奖池任务 */
//@Component
//@Configuration
public class PoolJob {
    @Autowired
    private RedisConfigService redisConfigService;

    //每天零点清小奖池用户数据
    @Scheduled(cron = "0 0 0 * * ?")
    public void refreshData(){
        System.out.println("清个人小奖池数据");
        clearUserData(20);
        System.out.println("清个人中奖池数据");
        clearUserData(40);
        System.out.println("清个人大奖池数据");
        clearUserData(500);
        System.out.println("清个人池数据完成");
    }

    private void clearUserData(int price) {
        //个人投入
        redisConfigService.removePattern("haoya:luck:"+price+":upay:*");
        //个人产出
        redisConfigService.removePattern("haoya:luck:"+price+":uincome:*");
        //个人总投入
        redisConfigService.removePattern("haoya:luck:"+price+":utotalpay:*");
        //个人总产出
        redisConfigService.removePattern("haoya:luck:"+price+":utotalincome:*");
    }
}

